<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title></title>
<link rel="stylesheet" type="text/css" href="/styles/general.css"/>
<link rel="stylesheet" type="text/css" href="/styles/main.css"/>
<link rel="stylesheet" type="text/css" href="/styles/pager.css"/>
<script src="/js/utils.js" type="text/javascript"></script>
<script src="/js/common.js" type="text/javascript"></script>
<script src="/js/jquery-1.3.2.min.js" type="text/javascript"></script>
<script src="/js/jquery.jeditable.mini.js" type="text/javascript"></script> 
<script src="/js/jquery.pager.js" type="text/javascript"></script> 
<script type="text/javascript" src="/popWindows/zDrag.js"></script>
<script type="text/javascript" src="/popWindows/zDialog.js"></script>
<script type="text/javascript" language="javascript"> 
var s="";
var pCount=1;
var page=1;
var projectid = $projectid;
var status = -1;
var style = 1;
function jsonsearch(json) {
		s="s="+json;
		//alert(s);
		PageClick(1);
}
function setiteminfo(num,pages,index){
	$("#iteminfo").html("(共"+num+"条  第"+index+"/"+pages+"页)");
}
function getallsdf(){
	location.href="/compound/tosdfall";
}
function getallexcel(){
	location.href="/compound/toexcelall";
}
function getsdf(){
	id="-1";
	$("input:checkbox[name=ids][checked]").each(function() {
	  id = id + "," + $(this).val(); 
	});
	if(id=="-1"){
		location.href="/compound/tosdfall";
		//alert("请选择需要导出的化合物");
		//return false;
	}else{
		location.href="/compound/tosdfbyid/id/"+id;
	}
}
function getexcel(){
	id="-1";
	$("input:checkbox[name=ids][checked]").each(function() {
	  id = id + "," + $(this).val(); 
	});
	if(id=="-1"){
		location.href="/compound/toexcelall";
		//alert("请选择需要导出的化合物");
		//return false;
	}else{
		location.href="/compound/toexcelbyid/id/"+id;
	}
	//location.href="/compound/toexcel/";
	//window.open("/compound/toexcel/");
}
jQuery.fn.extend({
	  doAjax: function() {
		if($(this).attr("href").indexOf("delete")>0)
	  	{
			if(!confirm("确定删除吗?"))return false;
		}
		$.ajax({			
	        url: $(this).attr("href"),
	        cache: false,
	        success: function(html){
				PageClick(page);
	        }
	    });
	  }
	});
PageClick = function(pageclickednumber) {
	page = pageclickednumber;
	$("#divtablelist").html("<div style='width:100%;text-align:center'><img src='/images/ajax_loader.gif'/></div>");
	$.ajax({
		type: "POST",
        //url: "/compound/indexAjax/page/"+pageclickednumber+"/s/"+s+"/",
        url: "/compound/indexAjax/style/"+style+"/projectid/"+projectid+"/status/"+status+"/page/"+pageclickednumber,
        data:s,
        cache: false,
        success: function(html){
            $("#divtablelist").html(html);
            $("#pager").pager({ pagenumber: pageclickednumber, pagecount: pCount, buttonClickCallback: PageClick });
            $('.compoundeditable').editable('/compound/modifyAjax/', {
            	indicator : '正在保存...',
            	tooltip   : '点击修改...',
            	onblur    : 'submit' 
            });
            $(".ajaxsubmit").click(
        			function(){
        			$(this).doAjax();
        			return false;
        	});
        	$(".openwin").click(
					function(){
						openwinx($(this).attr("href"),'sss','800','1000');
						return false;
			});
			$(".openwinsmall").click(
					function(){
						openwinx($(this).attr("href"),'sss','500','300');
						return false;
			});
        }
    });
}
$(document).ready(function() {
	$("#projectid").change(function() {
		if($("#projectid").val())
			projectid = $("#projectid").val();
			PageClick(1);
		// $.ajax({
			// type: "GET",
	        // url: "/compound/editstatusajax/projectid/"+projectid,
	        // cache: false,
	        // success: function(html){
	        	// $("#statuspan").html(html);
	        	// $("#statusid").change(function(){
					// if($("#statusid").val())
						// status = $("#statusid").val();
					// PageClick(1);
				// });
	        	// $("#statusid").trigger('change');
	        // }
        // })		
	});
	
	$("#projectid").trigger('change');
	//PageClick(1);
	$("#search").click(
			function(){
				s=encodeURIComponent($("#keyword").attr("value"));
				json="[{\"name\":\"any\",\"value\":\""+s+"\"}]";
				jsonsearch(json);
				}
			);
	$("#advsearch").click(
		function(){
			openwinx('/compound/advsearch','sss','800','500')
			//jsonsearch("a");
	});
	$("#keyword").keydown(function(event){ 
		if(event.which=="13"){
			$("#search").trigger('click');
		}
	});
	$("input:[name=styles]:radio").click(
		function(){
			style = $("input:[name=styles]:radio:checked").val();
			PageClick(page);
			//alert($("input:[name=styles]:radio:checked").val());
		}
	);
});
</script>
</head>
<body >
<h1>
<span class="action-span">
	<a href="#" onclick="getsdf();return false;">导出SDF</a>
	<a href="#" onclick="getexcel();return false;">导出Excel</a>
	<a href="/compound/add/">添加化合物</a></span>
<span class="action-span1">化合物管理</span>
<div style="clear:both"></div>
</h1>
<div class="form-div">
	<img src="/images/icon_search.gif" width="26" height="22" border="0" alt="SEARCH" />
    输入检索条件
    {form select * projectid projectid $projectid * * $projectlist}
    <span id="statuspan"> </span>
    <input type="text" name="keyword" id="keyword"/>
    <input type="button" id="search" value=" 检索 " />
    <!--{form chempop * keyword keyword} -->
     <input type="button" id="advsearch" value=" 高级检索 " />
     <span id="iteminfo"></span>
     <span id="divstyles" style="float:right">{form radio * styles styles 1 * * $styles}</span>
</div>
<div id='divtablelist'></div>
<div id="pager" style='align:center;' /></div>
<div style="clear:both"></div>
{template 'footer.html'}
</body>
</html>